<template>
  <div>
    <div class="setBox">
      <h3><span>冻结设置</span></h3>
      <div class="setContent">
      <el-card class="box-card" style="width:500px; margin:50px auto;">
        <div slot="header" class="clearfix">
          <span>请选择冻结时间点</span>
        </div>
        <el-date-picker style="width:100%" v-model="value1" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期"></el-date-picker>
        <div class="Explain">
          <p>备注：该冻结时间点设置后，补录时间点以及退费时间点不允许再选择该时间点之前！</p>
        </div>
        <div class="bts"><el-button @click="setTime" type="primary">确定冻结</el-button></div>
      </el-card>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ccc:'冻结设置',
      value1:''
    }
  },
  mounted() {
    this.getTime();
  },
  methods: {
    // 获取冻结时间
    getTime:function(){
      this.$api.systemSetup.GetFreezingTime().then(res=>{
        //console.log("获取冻结时间",res);
        this.value1 = res.data.result.configValue;
      })
    },
    setTime:function(){
      // var nt = this.formatDate(this.value1);
      // console.log(nt)
      this.$api.systemSetup.SetFreezingTime(this.value1).then(res=>{
        //console.log("保存冻结时间",res);
        if(res.data.status=='SUCCESS'){
          this.$message({
              message:'保存冻结时间成功!',
              type: 'success'
          })
          this.getTime();
        }else{
          this.$message.error(res.data.message);
        }
      })
    },
    // 时间设定
    formatDate:function(date){
      date = new Date(date);
      var y=date.getFullYear();
      var m=date.getMonth()+1;
      var d=date.getDate();
      var h=date.getHours();
      var m1=date.getMinutes();
      var s=date.getSeconds();
      m = m<10?("0"+m):m;
      d = d<10?("0"+d):d;
      h = h<10?("0"+h):h;
      m1 = m1<10?("0"+m1):m1;
      s = s<10?("0"+s):s;
      return y+"-"+m+"-"+d+" "+h+":"+m1+":"+s;
    }
  }
}
</script>
